﻿using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Pit.Application.Scheduler
{
    public class JobImplement : IJob
    {
        public void Execute(IJobExecutionContext context)
        {
            //try
            //{
            //    long jobId = context.JobDetail.JobDataMap.GetLong("JobId");
            //    //从作业调度容器里查找，如果找到，则运行
            //    var jobRuntimeInfo = JobPoolManager.Instance.Get(jobId);
            //    try
            //    {
            //        jobRuntimeInfo.Job.TryRun();
            //    }
            //    catch (Exception ex)
            //    {
            //        //写日志，任务调用失败
            //        ConnectionFactory.GetInstance<Provider.JobStateRepository>()
            //            .Update(new Provider.Tables.JobState()
            //            {
            //                JobId = jobId,
            //                RunState = (int)Provider.DirectiveType.Stop,
            //                UpdateTime = DateTime.Now
            //            });
            //        Common.Logging.LogManager.GetLogger(this.GetType()).Error(ex.Message, ex);
            //    }

            //}
            //catch (Exception ex)
            //{
            //    Common.Logging.LogManager.GetLogger(this.GetType()).Error(ex.Message, ex);
            //    //调用的时候失败，写日志，这里错误，属于系统级错误，严重错误
            //}
        }
    }
}
